﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using AI_Tank.Game;
using AI_Tank.MapDrawer;
namespace MapDrawer.MapDrawer
{
    public class GameMapDrawer
    {
        private int mapWidth, mapHeight;
        private int greenTeamID;
        private readonly int totalFrame;
        private readonly int totalTime;
        private int nowFrame;
        private float bulletMovePerFrame;
        private float tankMovePerFrame;
        private readonly int interval;
        private int gridSize = 32;
        private Action<Bitmap> timerDrawCallback;

        private bool isFirstRound = true;
        private AI_Tank.Game.RoundData lastRound;
        private AI_Tank.Game.RoundData nowRound;
        private Dictionary<int, Direction> lastDirection;
        private Timer timer;

        public GameMapDrawer(int greenTeamID, Action<Bitmap> timerDrawCallback = null, int totalTime = 1000, int totalFrame = 20)
        {
            this.greenTeamID = greenTeamID;
            this.totalFrame = totalFrame;
            this.totalTime = totalTime;
            interval = totalTime / totalFrame;
            if (interval <= 0)
                interval = 1;
            this.timerDrawCallback = timerDrawCallback;

            bulletMovePerFrame = ((float)gridSize * 3) / totalFrame;
            tankMovePerFrame = (float)gridSize / totalFrame;
        }

        public void LegStart(LegStartData data)
        {
            isFirstRound = true;
            mapWidth = data.MapWidth;
            mapHeight = data.MapHeight;
        }

        public void Round(AI_Tank.Game.RoundData round)
        {
            nowFrame = 0;
            if (lastRound != null)
                isFirstRound = false;
            nowRound = round;

            if (timer != null)
                timer.Dispose();
            timer = new Timer(OnTimerDraw, null, interval, interval);
        }

        Bitmap bitmap;
        private void OnTimerDraw(object state)
        {
            nowFrame++;
            bitmap = new Bitmap(mapWidth * gridSize, mapHeight * gridSize);
            Graphics g = Graphics.FromImage(bitmap);

            DrawMapGrass(ref g);
            
            DrawGameMapElement(ref g);
            if (nowFrame != totalFrame)//最后一桢不画子弹
                DrawBullet(ref g, nowFrame);
            if (isFirstRound)
            {
                DrawTanksStop(ref g);
            }
            else
            {
                DrawTanksMove(ref g, nowFrame);
            }

            timerDrawCallback?.Invoke(bitmap);
            if (nowFrame == totalFrame)//最后一桢
            {
                lastRound = nowRound;
                timer.Dispose();
                return;
            }
        }

        private void DrawGameMapElement(ref Graphics g)
        {
            foreach (var item in nowRound.Goods)
                DrawOneMapElement(ref g, item, item.Position.X * gridSize, item.Position.Y * gridSize);
        }

        private void DrawMapGrass(ref Graphics g)
        {
            int drawX = 0, drawY = 0;
            for (int j = 0; j < mapHeight; j++)
            {
                drawX = 0;
                for (int i = 0; i < mapWidth; i++)
                {
                    
                    g.DrawImage(AI_Tank.MapDrawer.Images.MapElementImages.grass, drawX, drawY, gridSize, gridSize);
                    drawX = drawX + gridSize;
                }
                drawY = drawY + gridSize;
            }
        }

        private void DrawOneMapElement(ref Graphics g, Goods goods, int drawX, int drawY)
        {
            switch (goods.ElementType)
            {
                case ElementType.BrickWall:
                    g.DrawImage(AI_Tank.MapDrawer.Images.MapElementImages.wall, drawX, drawY, gridSize, gridSize);
                    break;
                case ElementType.IronWall:
                    g.DrawImage(AI_Tank.MapDrawer.Images.MapElementImages.ironwall, drawX, drawY, gridSize, gridSize);
                    break;
                case ElementType.River:
                    g.DrawImage(AI_Tank.MapDrawer.Images.MapElementImages.river, drawX, drawY, gridSize, gridSize);
                    break;
                case ElementType.Coin:
                    DrawCoin(ref g, ref goods, drawX, drawY);
                    break;
                case ElementType.Star:
                    g.DrawImage(AI_Tank.MapDrawer.Images.MapElementImages.star, drawX, drawY, gridSize, gridSize);
                    break;
                case ElementType.Nothing:
                    g.DrawImage(AI_Tank.MapDrawer.Images.MapElementImages.grass, drawX, drawY, gridSize, gridSize);
                    break;
                default:
                    break;
            }
        }

        private void DrawCoin(ref Graphics g, ref Goods goods, int drawX, int drawY)
        {
            switch (((Coin)goods).Point)
            {
                case 1:
                    g.DrawImage(AI_Tank.MapDrawer.Images.MapWallettImages.wallet_1, drawX, drawY, gridSize, gridSize);
                    break;
                case 2:
                    g.DrawImage(AI_Tank.MapDrawer.Images.MapWallettImages.wallet_2, drawX, drawY, gridSize, gridSize);
                    break;
                case 3:
                    g.DrawImage(AI_Tank.MapDrawer.Images.MapWallettImages.wallet_3, drawX, drawY, gridSize, gridSize);
                    break;
                case 4:
                    g.DrawImage(AI_Tank.MapDrawer.Images.MapWallettImages.wallet_4, drawX, drawY, gridSize, gridSize);
                    break;
                case 5:
                    g.DrawImage(AI_Tank.MapDrawer.Images.MapWallettImages.wallet_5, drawX, drawY, gridSize, gridSize);
                    break;
                default:
                    break;
            }
        }

        private void DrawTanksStop(ref Graphics g)
        {
            lastDirection = new Dictionary<int, Direction>();
            foreach (var item in nowRound.Players)
            {
                bool hasDraw = false;
                if (item.TeamID == greenTeamID)//选取颜色
                {
                    for (int i = 0; i < nowRound.Bullets.Count; i++)
                    {
                        if (nowRound.Bullets[i].Position.X == item.Position.X && nowRound.Bullets[i].Position.Y == item.Position.Y)
                        {
                            DrawDirectionGreenTank(ref g, nowRound.Bullets[i].Direction, nowRound.Bullets[i].Direction, item.Position.X * gridSize, item.Position.Y * gridSize, 0, item.Id);
                            SetTankMoveDirection(item.Id, nowRound.Bullets[i].Direction);
                            hasDraw = true;
                        }
                    }
                    if (hasDraw == false)
                    {
                        DrawDirectionGreenTank(ref g, Direction.Up, Direction.Up, item.Position.X * gridSize, item.Position.Y * gridSize, 0, item.Id);
                        SetTankMoveDirection(item.Id, Direction.Up);
                    }
                }
                else
                {
                    for (int i = 0; i < nowRound.Bullets.Count; i++)
                    {
                        if (nowRound.Bullets[i].Position.X == item.Position.X && nowRound.Bullets[i].Position.Y == item.Position.Y)
                        {
                            DrawDirectionRedTank(ref g, nowRound.Bullets[i].Direction, nowRound.Bullets[i].Direction, item.Position.X * gridSize, item.Position.Y * gridSize, 0, item.Id);
                            SetTankMoveDirection(item.Id, nowRound.Bullets[i].Direction);
                            hasDraw = true;
                        }
                    }
                    if (hasDraw == false)
                    {
                        DrawDirectionRedTank(ref g, Direction.Up, Direction.Up, item.Position.X * gridSize, item.Position.Y * gridSize, 0, item.Id);
                        SetTankMoveDirection(item.Id, Direction.Up);
                    }
                }
            }
        }

        private void SetTankMoveDirection(int id, Direction direction)
        {
            if (lastDirection.ContainsKey(id))
                lastDirection[id] = direction;
            else
                lastDirection.Add(id, direction);

        }

        private Direction GetTankLastMoveDirection(int id)
        {
            if (lastDirection.ContainsKey(id))
                return lastDirection[id];
            return Direction.Up;
        }

        private void DrawTanksMove(ref Graphics g, int frame)
        {
            float tankMoveLength;
            if (frame == totalFrame)
                tankMoveLength = gridSize;
            else
                tankMoveLength = tankMovePerFrame * (frame - 1);
            Point? exitstLastPoint;
            Point lastPoint;
            Direction? existMoveDirection;
            Direction moveDirection;

            foreach (var item in nowRound.Players)
            {
                bool hasDraw = false;
                exitstLastPoint = GetTankPositionByID(item.Id);
                if (exitstLastPoint == null)
                    continue;
                lastPoint = new Point(exitstLastPoint.Value.X, exitstLastPoint.Value.Y);

                existMoveDirection = GetTankMoveDirection(new Point(item.Position.X, item.Position.Y), lastPoint);



                if (existMoveDirection == null)//未移动
                {
                    moveDirection = GetTankLastMoveDirection(item.Id);
                    foreach (var bullet in nowRound.Bullets)
                    {
                        if (bullet.TeamID == item.TeamID)//发射子弹
                        {
                            if (item.TeamID == greenTeamID)//绿色坦克
                                DrawDirectionGreenTank(ref g, moveDirection, bullet.Direction, lastPoint.X * gridSize, lastPoint.Y * gridSize, 0, item.Id);
                            else
                                DrawDirectionRedTank(ref g, moveDirection, bullet.Direction, lastPoint.X * gridSize, lastPoint.Y * gridSize, 0, item.Id);
                            hasDraw = true;
                            break;
                        }
                    }
                    if (hasDraw == false)//未发射子弹
                    {
                        if (item.TeamID == greenTeamID)//绿色坦克
                            DrawDirectionGreenTank(ref g, moveDirection, moveDirection, lastPoint.X * gridSize, lastPoint.Y * gridSize, 0, item.Id);
                        else
                            DrawDirectionRedTank(ref g, moveDirection, moveDirection, lastPoint.X * gridSize, lastPoint.Y * gridSize, 0, item.Id);
                    }
                }
                else//移动
                {
                    moveDirection = existMoveDirection.Value;



                    foreach (var bullet in nowRound.Bullets)
                    {
                        if (bullet.TeamID == item.TeamID)//发射子弹
                        {
                            if (item.TeamID == greenTeamID)//绿色坦克
                                DrawDirectionGreenTank(ref g, moveDirection, bullet.Direction, lastPoint.X * gridSize, lastPoint.Y * gridSize, tankMoveLength, item.Id);
                            else
                                DrawDirectionRedTank(ref g, moveDirection, bullet.Direction, lastPoint.X * gridSize, lastPoint.Y * gridSize, tankMoveLength, item.Id);
                            hasDraw = true;
                            break;
                        }
                    }
                    if (hasDraw == false)//未发射子弹
                    {
                        if (item.TeamID == greenTeamID)//绿色坦克
                            DrawDirectionGreenTank(ref g, moveDirection, moveDirection, lastPoint.X * gridSize, lastPoint.Y * gridSize, tankMoveLength, item.Id);
                        else
                            DrawDirectionRedTank(ref g, moveDirection, moveDirection, lastPoint.X * gridSize, lastPoint.Y * gridSize, tankMoveLength, item.Id);
                    }
                }
                g.DrawString($"({item.Position.X},{item.Position.Y})", new Font("微软雅黑", 16), new SolidBrush(Color.Pink), new PointF(item.Position.X * gridSize, item.Position.Y * gridSize));
                SetTankMoveDirection(item.Id, moveDirection);//保存当前回合的坦克移动方向
            }
        }

        private Direction? GetTankMoveDirection(Point now, Point last)
        {
            if (now.X > last.X)
            {
                return Direction.Right;
            }
            else if (now.X < last.X)
            {
                return Direction.Left;
            }
            else if (now.Y > last.Y)
            {
                return Direction.Down;
            }
            else if (now.Y < last.Y)
            {
                return Direction.Up;
            }
            else
            {
                return null;
            }
        }

        private Point? GetTankPositionByID(int id)
        {
            foreach (var item in lastRound.Players)
            {
                if (item.Id == id)
                {
                    return new Point(item.Position.X, item.Position.Y);
                }
            }
            return null;
        }

        private void DrawDirectionGreenTank(ref Graphics g, Direction moveDirection, Direction bulletDirection, int drawX, int drawY, float moveLength, int id = -1)
        {
            switch (moveDirection)
            {
                case Direction.Up:
                    drawY -= ((int)moveLength);
                    break;
                case Direction.Right:
                    drawX += ((int)moveLength);
                    break;
                case Direction.Down:
                    drawY += ((int)moveLength);
                    break;
                case Direction.Left:
                    drawX -= ((int)moveLength);
                    break;
                default:
                    break;
            }
            if (moveDirection == Direction.Left || moveDirection == Direction.Right)
            {
                switch (bulletDirection)
                {
                    case Direction.Up:
                        g.DrawImage(AI_Tank.MapDrawer.Images.GreenTankImages.green_1_up, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Right:
                        g.DrawImage(AI_Tank.MapDrawer.Images.GreenTankImages.green_1_right, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Down:
                        g.DrawImage(AI_Tank.MapDrawer.Images.GreenTankImages.green_1_down, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Left:
                        g.DrawImage(AI_Tank.MapDrawer.Images.GreenTankImages.green_1_left, drawX, drawY, gridSize, gridSize);
                        break;
                    default:
                        break;
                }
            }
            else
            {
                switch (bulletDirection)
                {
                    case Direction.Up:
                        g.DrawImage(AI_Tank.MapDrawer.Images.GreenTankImages.green_2_up, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Right:
                        g.DrawImage(AI_Tank.MapDrawer.Images.GreenTankImages.green_2_right, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Down:
                        g.DrawImage(AI_Tank.MapDrawer.Images.GreenTankImages.green_2_down, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Left:
                        g.DrawImage(AI_Tank.MapDrawer.Images.GreenTankImages.green_2_left, drawX, drawY, gridSize, gridSize);
                        break;
                    default:
                        break;
                }
            }
            if (id >= 0)
                g.DrawString(id.ToString(), new Font("微软雅黑", 20), new SolidBrush(Color.White), new PointF(drawX, drawY));

        }

        private void DrawDirectionRedTank(ref Graphics g, Direction moveDirection, Direction bulletDirection, int drawX, int drawY, float moveLength, int id = -1)
        {
            switch (moveDirection)
            {
                case Direction.Up:
                    drawY -= ((int)moveLength);
                    break;
                case Direction.Right:
                    drawX += ((int)moveLength);
                    break;
                case Direction.Down:
                    drawY += ((int)moveLength);
                    break;
                case Direction.Left:
                    drawX -= ((int)moveLength);
                    break;
                default:
                    break;
            }
            if (moveDirection == Direction.Left || moveDirection == Direction.Right)
            {
                switch (bulletDirection)
                {
                    case Direction.Up:
                        g.DrawImage(AI_Tank.MapDrawer.Images.RedTankImages.red_1_up, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Right:
                        g.DrawImage(AI_Tank.MapDrawer.Images.RedTankImages.red_1_right, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Down:
                        g.DrawImage(AI_Tank.MapDrawer.Images.RedTankImages.red_1_down, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Left:
                        g.DrawImage(AI_Tank.MapDrawer.Images.RedTankImages.red_1_left, drawX, drawY, gridSize, gridSize);
                        break;
                    default:
                        break;
                }
            }
            else
            {
                switch (bulletDirection)
                {
                    case Direction.Up:
                        g.DrawImage(AI_Tank.MapDrawer.Images.RedTankImages.red_2_up, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Right:
                        g.DrawImage(AI_Tank.MapDrawer.Images.RedTankImages.red_2_right, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Down:
                        g.DrawImage(AI_Tank.MapDrawer.Images.RedTankImages.red_2_down, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Left:
                        g.DrawImage(AI_Tank.MapDrawer.Images.RedTankImages.red_2_left, drawX, drawY, gridSize, gridSize);
                        break;
                    default:
                        break;
                }
            }
            if (id >= 0)
                g.DrawString(id.ToString(), new Font("微软雅黑", 20), new SolidBrush(Color.Black), new PointF(drawX, drawY));
        }

        private void DrawBullet(ref Graphics g, int frame)
        {
            float bulletMoveLength;
            if (frame == totalFrame - 1)
                bulletMoveLength = gridSize * 3;
            else
                bulletMoveLength = bulletMovePerFrame * frame;

            foreach (var item in nowRound.Bullets)
            {
                if (item.TeamID == greenTeamID)
                {
                    DrawDirectionGreenBullet(ref g, item.Direction, item.Type == BulletType.Super, item.Position.X * gridSize, item.Position.Y * gridSize, bulletMoveLength);
                    g.DrawString($"({item.Position.X},{item.Position.Y})", new Font("微软雅黑", 10), new SolidBrush(Color.White), new PointF(item.Position.X * gridSize, item.Position.Y * gridSize));
                }
                else
                {
                    DrawDirectionRedBullet(ref g, item.Direction, item.Type == BulletType.Super, item.Position.X * gridSize, item.Position.Y * gridSize, bulletMoveLength);
                    g.DrawString($"({item.Position.X},{item.Position.Y})", new Font("微软雅黑", 10), new SolidBrush(Color.White), new PointF(item.Position.X * gridSize, item.Position.Y * gridSize));
                }
            }
        }

        private void DrawDirectionGreenBullet(ref Graphics g, Direction direction, bool isSuper, int drawX, int drawY, float moveLength)
        {
            switch (direction)
            {
                case Direction.Up:
                    drawY -= (int)moveLength;
                    break;
                case Direction.Right:
                    drawX += (int)moveLength;
                    break;
                case Direction.Down:
                    drawY += (int)moveLength;
                    break;
                case Direction.Left:
                    drawX -= (int)moveLength;
                    break;
                default:
                    break;
            }
            if (isSuper == false)
            {
                switch (direction)
                {
                    case Direction.Up:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_up, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Right:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_right, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Down:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_down, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Left:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_left, drawX, drawY, gridSize, gridSize);
                        break;
                    default:
                        break;
                }
            }
            else
            {
                switch (direction)
                {
                    case Direction.Up:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_superbullet, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Right:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_superbullet, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Down:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_superbullet, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Left:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_superbullet, drawX, drawY, gridSize, gridSize);
                        break;
                    default:
                        break;
                }
            }
           // g.DrawString($"({drawX},{drawY})", new Font("微软雅黑", 10), new SolidBrush(Color.White), new PointF(drawX, drawY));

            //if (isSuper == false)
            //{
            //    switch (direction)
            //    {
            //        case Direction.Up:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_up, drawX, drawY - moveLength + gridSize, gridSize, gridSize);
            //            break;
            //        case Direction.Right:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_right, drawX + moveLength - gridSize, drawY, gridSize, gridSize);
            //            break;
            //        case Direction.Down:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_down, drawX, drawY + moveLength - gridSize, gridSize, gridSize);
            //            break;
            //        case Direction.Left:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_left, drawX - moveLength + gridSize, drawY, gridSize, gridSize);
            //            break;
            //        default:
            //            break;
            //    }
            //}
            //else
            //{
            //    switch (direction)
            //    {
            //        case Direction.Up:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_superbullet, drawX, drawY - moveLength + gridSize, gridSize, gridSize);
            //            break;
            //        case Direction.Right:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_superbullet, drawX + moveLength - gridSize, drawY, gridSize, gridSize);
            //            break;
            //        case Direction.Down:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_superbullet, drawX, drawY + moveLength - gridSize, gridSize, gridSize);
            //            break;
            //        case Direction.Left:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.green_superbullet, drawX - moveLength + gridSize, drawY, gridSize, gridSize);
            //            break;
            //        default:
            //            break;
            //    }
            //}
        }

        private void DrawDirectionRedBullet(ref Graphics g, Direction direction, bool isSuper, int drawX, int drawY, float moveLength)
        {
            switch (direction)
            {
                case Direction.Up:
                    drawY -= (int)moveLength;
                    break;
                case Direction.Right:
                    drawX += (int)moveLength;
                    break;
                case Direction.Down:
                    drawY += (int)moveLength;
                    break;
                case Direction.Left:
                    drawX -= (int)moveLength;
                    break;
                default:
                    break;
            }
            if (isSuper == false)
            {
                switch (direction)
                {
                    case Direction.Up:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_up, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Right:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_right, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Down:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_down, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Left:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_left, drawX, drawY, gridSize, gridSize);
                        break;
                    default:
                        break;
                }
            }
            else
            {
                switch (direction)
                {
                    case Direction.Up:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_superbullet, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Right:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_superbullet, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Down:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_superbullet, drawX, drawY, gridSize, gridSize);
                        break;
                    case Direction.Left:
                        g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_superbullet, drawX, drawY, gridSize, gridSize);
                        break;
                    default:
                        break;
                }
            }
           // g.DrawString($"({drawX},{drawY})", new Font("微软雅黑", 10), new SolidBrush(Color.White), new PointF(drawX, drawY));

            //if (isSuper == false)
            //{
            //    switch (direction)
            //    {
            //        case Direction.Up:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_up, drawX, drawY - moveLength + gridSize, gridSize, gridSize);
            //            break;
            //        case Direction.Right:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_right, drawX + moveLength - gridSize, drawY, gridSize, gridSize);
            //            break;
            //        case Direction.Down:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_down, drawX, drawY + moveLength - gridSize, gridSize, gridSize);
            //            break;
            //        case Direction.Left:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_left, drawX - moveLength + gridSize, drawY, gridSize, gridSize);
            //            break;
            //        default:
            //            break;
            //    }
            //}
            //else
            //{
            //    switch (direction)
            //    {
            //        case Direction.Up:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_superbullet, drawX, drawY - moveLength + gridSize, gridSize, gridSize);
            //            break;
            //        case Direction.Right:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_superbullet, drawX + moveLength - gridSize, drawY, gridSize, gridSize);
            //            break;
            //        case Direction.Down:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_superbullet, drawX, drawY + moveLength + gridSize, gridSize, gridSize);
            //            break;
            //        case Direction.Left:
            //            g.DrawImage(AI_Tank.MapDrawer.Images.BulletImages.yellow_superbullet, drawX - moveLength + gridSize, drawY, gridSize, gridSize);
            //            break;
            //        default:
            //            break;
            //    }
            //}
        }
    }
}
